package com.zt.dev.semiPhysicalEquipment.util;

import org.springframework.util.StringUtils;

public class StrUtils {

    /**
     * 处理字符串
     * 去掉最后一个逗号、去空
     * @param str
     * @return
     */
    public static String strReg(String str){
        return str.substring(0, str.length() - 1).trim();
    }

    /**
     * 字符串转换成int数组
     * @param str
     * @return
     */
    public static int[] strToArry(String str){
        if (!StringUtils.isEmpty(str)){
            String[] split = str.split(",");
            int[] a = new int[split.length] ;
            for (int i = 0; i < split.length; i++) {
                a[i] =  Integer.parseInt(split[i]);
            }
            return a;
        }
        return null;
    }
}
